﻿@using System.Globalization
@using iPanel.Model
@using iPanel.Resources
@using iPanel.Utils
@using Humanizer
@inject IStringLocalizer<Dialogs> Loc

<FluentDialogBody>
    <FluentStack Orientation="Orientation.Vertical" Style="display: flex; height: 100%" VerticalGap="12">
        <div>
            <FluentRadioGroup TValue="string"
                              Label="@Loc[nameof(Dialogs.SettingsDialogTheme)]"
                              @bind-Value="@_currentSetting"
                              @bind-Value:after="ThemeChangedAsync"
                              Orientation="Orientation.Vertical">
                <FluentRadio Value="@ThemeManager.ThemeSettingSystem">@Loc[nameof(Dialogs.SettingsDialogSystemTheme)]</FluentRadio>
                <FluentRadio Value="@ThemeManager.ThemeSettingLight">@Loc[nameof(Dialogs.SettingsDialogLightTheme)]</FluentRadio>
                <FluentRadio Value="@ThemeManager.ThemeSettingDark">@Loc[nameof(Dialogs.SettingsDialogDarkTheme)]</FluentRadio>
            </FluentRadioGroup>
        </div>

        <div>
            <FluentSelect
                TOption="CultureInfo"
                Immediate="true"
                Position="SelectPosition.Below"
                Label="@Loc[nameof(Dialogs.SettingsDialogLanguage)]"
                Items="@_languageOptions"
                OptionText="@(c => c.NativeName.Humanize())"
                @bind-SelectedOption="@_selectedUiCulture"
                @bind-SelectedOption:after="@OnLanguageChanged"
                Class="language-select"/>

            <p class="setting-subtext">@Loc[nameof(Dialogs.SettingsDialogLanguagePageReloads)]</p>
        </div>

        <div>
            <span class="setting-title">@Loc[nameof(Dialogs.SettingsDialogDashboardLogsAndTelemetry)]</span>
            <div>
                <FluentButton IconStart="@(new Icons.Regular.Size16.Delete())"
                              OnClick="ClearAllSignals"
                              Title="@Loc[nameof(Dialogs.SettingsRemoveAllButtonText)]"
                              aria-label="@Loc[nameof(Dialogs.SettingsRemoveAllButtonText)]">
                    @Loc[nameof(Dialogs.SettingsRemoveAllButtonText)]
                </FluentButton>
            </div>
        </div>

        <div class="version">@string.Format(Loc[nameof(Dialogs.SettingsDialogVersion)], VersionHelpers.DashboardDisplayVersion)</div>
    </FluentStack>
</FluentDialogBody>
